package com.lx.video.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lx.bilibili.entity.Video;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public interface VideoMapper extends BaseMapper<Video> {

    @Select("SELECT\n" +
            "	* \n" +
            "FROM\n" +
            "	`user` a,\n" +
            "	video b \n" +
            "WHERE\n" +
            "	a.id = b.uid \n" +
            "	AND a.id = #{id} AND b.state = 1 \n" +
            "ORDER BY\n" +
            "	b.vcount DESC \n" +
            "	LIMIT #{page},\n" +
            "	#{limit}")
    List<Video> getHotVideoByIdLimit(int id, int page, int limit);

    @Select("SELECT\n" +
            "	sum( vcount ) \n" +
            "FROM\n" +
            "	video \n" +
            "WHERE\n" +
            "	uid = #{uid}")

    int getVcountByUid(int uid);



    @Select("SELECT\n" +
            "	b.* \n" +
            "FROM\n" +
            "	videodatadetail a,\n" +
            "	video b \n" +
            "WHERE\n" +
            "	a.vid = b.id \n" +
            "	AND a.uid = #{uid} \n" +
            "	AND a.collect = 1 \n" +
            "ORDER BY\n" +
            "	a.TIME DESC \n" +
            "	LIMIT #{page},#{limit}")

    List<Video> getCollection(int uid, int page, int limit);
}
